package com.cfl.day1.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
//扫描dao接口
@MapperScan("com.web.app.dao")
public class PageConfig {

    @Bean
    public MybatisPlusInterceptor getPageInterceptor(){
        //声明MybatisPlusInterceptor的变量
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //向变量里添加PaginationInnerInterceptor告诉paginationInnerInterceptor 需要的数据库是DbType.MYSQL
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return mybatisPlusInterceptor;
    }
}
